<!doctype html>
<html>
<link href="res/common.css" rel="stylesheet" type="text/css">
<link href="res/index/css/activity.css" rel="stylesheet" type="text/css">
<!-- InstanceBegin template="/Templates/biTemplate.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta charset="utf-8">
<meta id="viewport" name="viewport" content="width=device-width,initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0,user-scalable=no,target-densitydpi=300">
<!-- InstanceBeginEditable name="doctitle" -->
<title>智能云管家-VIP秒杀</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="EditRegion-jscode" -->
<script src="http://bj.911860.com/www/resources/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript">
function detectDeviceType(){
	var isIphone =navigator.userAgent.indexOf("iPhone") != -1;
	var isIpod = navigator.userAgent.indexOf("iPod") != -1 ;
	var isIpad = navigator.userAgent.indexOf("iPad") != -1 ;
	
	var isAndroid = navigator.userAgent.indexOf("Android") != -1 ;
	var isIos = isIphone || isIpod || isIpad ;
	return isIos?"Apple":"Android";
} 
function getQueryParameter(qs)  
{  
	var s = location.href;  
	s = s.replace("?","?&").split("&");//这样可以保证第一个参数也能分出来 
	var re = "";  
	for(i=1;i<s.length;i++)  
		if(s[i].indexOf(qs+"=")==0)  
			re = s[i].replace(qs+"=","");//取代前面的参数名，只剩下参数值  
			  
	return re;  
} 
var apx = 0;
var jsonserver="http://bj.911860.com/mobile-html5-rest/";
jsonserver="http://192.168.6.61:8580/mobile-html5-rest/";
var type = getQueryParameter("type");
var SysSecond,InterValObj,oInterval; 

var url = jsonserver+"newFlow/killpage/"+window.localStorage.getItem("curphone")+"/"+type;
$(document).ready(function(e) {
	checkPosition();
    if(detectDeviceType()=="Apple"){
		$("#viewport").attr("content","width=640,initial-scale=0.5, maximum-scale=0.5, minimum-scale=0.5,user-scalable=no");
	}
	
	window.scrollTo(0,1);
	if(type=="m"){
		$("#cardimg1").attr("src","res/img/adtivity/vipcard.png");
		$("#prize_txt").html("产品介绍：1000元当当网购物卡，可在当当网使用；<br>参与条件：上月流量满50MB;<br>获奖规则:活动开始后前2名成功秒杀的用户即可中奖。");
	}else if(type=="x"){
		$("#cardimg1").attr("src","res/img/adtivity/469.png");
		$("#prize_txt").html("产品介绍：小米1s依然是主频最快的双核处理器，经典机型！奖品以收到的实物为准。<br>参与条件：上月流量满50MB，且通过活动页成功下载沃友客户端<br>获奖规则：活动开始后前2名成功秒杀的用户即可中奖。");
	}else if(type=="i"){
		$("#cardimg1").attr("src","res/img/adtivity/ipad4.png");
		$("#prize_txt").html("产品介绍：ipad4平板电脑，一如既往的卓越体验！奖品以收到的实物为准。<br>参与条件：上月流量满50MB，且通过活动页成功下载沃友客户端；<br>获奖规则：活动开始后前1名成功秒杀的用户即可中奖。");
	}
	
	$.getJSON(url+".jsonp?callback=?",{},function(data){
		
		if(data.startKillTimes!=null){
			var oTime=data.overKillTimes*1;
				oInterval=setInterval(function(){
					//alert(1);
					if(oTime<=0){
						clearInterval(oInterval);
						$("#remainTimeDiv").text("秒杀已结束");
					}
			},500);
			if(data.overKillTimes>=0){
			 SysSecond = parseInt(data.startKillTimes); //这里获取倒计时的起始时间 
	  		 InterValObj = window.setInterval(SetRemainTime, 1000); //间隔函数，1秒执行 
			}
		}
		//秒杀按钮状态判断
		if(data.killFlag*1&&data.overKillTimes>=0){
			bindkill();
		}
		$("#date").text(data.nextDate);
		
		$("#peocount").text(data.preMonthApplyCount);
		if(data.yesflag=="0"){
			$("#killdettxt").html("下次再来试试运气吧！");
		}
		$("#loading").hide();
		$(".floatBoxBg").hide();
	});
});
//将时间减去1秒，计算天、时、分、秒 
function SetRemainTime() { 
  if (SysSecond > 0) { 
	   SysSecond = SysSecond - 1; 
	   var second = processTime(Math.floor(SysSecond % 60));             // 计算秒     
	   var minite = processTime(Math.floor((SysSecond / 60) % 60));      //计算分 
	   var hour = processTime(Math.floor((SysSecond / 3600) % 24));      //计算小时 
	   $("#remainTimeDiv").text("距离秒杀开始:"+ hour + "小时" + minite + "分" + second + "秒"); 
  } else {//剩余时间小于或等于0的时候，就停止间隔函数 
	   window.clearInterval(InterValObj); 
	   $("#remainTimeDiv").text("秒杀进行中");
	   $.getJSON(url+".jsonp?callback=?",{},function(data){
		   if(data.killFlag*1 && data.overKillTimes>=0){
				bindkill();
			}
		});
  } 
} 
function processTime(t){
	return t>=10?t:'0'+t;
}
function bindkill(){
	$("#killbtn").attr("src","res/img/adtivity/killbtn.png");
	
	$("#killbtn").unbind("click").bind("click",function(){
		$(this).attr("src","res/img/adtivity/killoff.png");
		var killurl = jsonserver+"newFlow/getbusi/"+localStorage.getItem("curphone")+"/"+type;
		$.getJSON(killurl+".jsonp?callback=?",{},function(data){
			c('<div style="text-align:center;heigth:200px;">再接再厉</div><div style="text-align:center">动作有点慢,下次再试吧!</div>',"confirmpress()");
		})
	});
}
function confirmpress(){
	cancel();
	$("#killbtn").unbind("click");
	$("#killbtn").attr("src","res/img/adtivity/killoff.png");
	
}
function checkPosition()
{
	
	
	var toNum=$("#temp_div");
	var inputOffset=toNum.offset();
	 if(detectDeviceType()=="Apple"){
		apx = 35;
	}
	$("#showmsg").css({
			"width":"70%",
			"left":(inputOffset.left+apx)+"px",
			"top":(inputOffset.top+400)+"px",
			"z-index":"98",
			"position":"absolute"
	});

	
	$("#childshow").css({
			"width":"70%",
			"left":(inputOffset.left+6+apx)+"px",
			"top":(inputOffset.top+406)+"px",
			"z-index":"99",
			"position":"absolute"
			});
}

function c(alertText,eventName)
{
	$("#showmsg").fadeIn();
	$("#childshow").fadeIn();
	$("#alertText").html(alertText);
	$("#okBtn").attr("onClick",eventName);
}

function cancel()
{
	$("#showmsg").fadeOut(500);
	$("#childshow").fadeOut(500);
}

</script>
<style type="text/css">

#showmsg{
	background-color:#FFF; 
	height:280px;
	border:6px solid #8fb7df;
	opacity:0.9;
	display:none; 
	border-radius:12px;
}
#temp_div{
	margin:300px auto;
	opacity:0.9;
	border-radius:12px;
}
#childshow
{
	background-image:url(res/index/images/bg1.jpg); 
	 height:280px;
	 display:none;
	 border-radius:12px;
}
</style>
<!-- InstanceEndEditable -->
<style type="text/css">
*{
	font-family:Heiti SC;
	font-weight:600;
}
</style>
	<script type="text/javascript">
//var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
//document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3F2284c04845acdcd94dd640a8555927dc' type='text/javascript'%3E%3C/script%3E"));
</script>

</head>


<link rel="icon" href="res/img/logo.png" type="image/x-icon">
<link rel="shortcut icon" href="res/img/logo.png" type="image/x-icon"> 
<body style="margin:0;">
	<div id="temp_div" style="width:70%; margin:0px auto;height:1px;"></div>
	<div id="header">
	<!-- InstanceBeginEditable name="EditRegion-header" -->
    <table width="100%" height="88px">
    	<tr>
        	<td width="10%" onClick="javascript:location.href='activity.html'">
            <div><img src="res/img/back.png"/></div>
            </td>
            <td width="80%">
            <span style="font-size:34px; font-weight:bold; color:#fff;">北京联通流量有奖活动</span>
            </td>
            <td width="10%">
            
            </td>
        </tr>
    </table>
	<!-- InstanceEndEditable -->
    </div>
    <div id="content">
	  <div id="childshow">
    	<!--<div style="width:100%"><img width="100%" src="res/img/billdet/jianbian.png" height="17"/></div>-->
        <div align="center" id="alertText" style="color:#4471b5; font-family:'黑体'; font-size:38px; font-weight:bold; margin-top:20px;"></div>
        
         <div style=" margin-top:35px;text-align:center; "><img src="res/img/billdet/OKBtn.png" id="okBtn" /></div>
       <!-- <img width="100%" src="res/img/billdet/jianbian.png" height="15" style="width:100%; position:relative; top:38px;"/>-->
  
    </div>
	<div id="showmsg"></div>
    <div id="loading" class="loading"><img src="res/loading.gif"/>载入中...</div>
    <div class="floatBoxBg"></div>
	<!-- InstanceBeginEditable name="EditRegion-content" -->
    <div id="cardinfo" class="cardinfo">
    	<div id="cardimg" class="cardimg"><img id="cardimg1" width="294" src="res/img/adtivity/vipcard.png"/></div>
        <div id="cardtxt" class="cardtxt">本期秒杀开始时间<br><span id="date"></span><br><div id="killdettxt"><span>目前已有<span id="peocount"></span>人获得秒杀资格</span></div></div>
    </div>
    <div id="kill" class="kill">
        <div style="font-size:32px;color:#435B77;margin-bottom:10px; height:40px;" id="remainTimeDiv"></div> 
        <img id="killbtn" src="res/img/adtivity/killoff.png"/>
    </div>
    <div id="giftintr" class="giftintr">最给力最实惠的惊喜大奖，动作要快哦！<br><span id="prize_txt">1000元购物卡适用范围:可在当当网使用；<br>获奖规则:活动开始后前2名成功秒杀的用户即可中奖。</span></div>
	<!-- InstanceEndEditable -->
    </div>
    <!-- InstanceBeginEditable name="EditRegion-footer" -->
	<!-- InstanceEndEditable -->
    <div id="footer">
    </div>
    
</body>
<!-- InstanceEnd --></html>
